home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / progs / editor / frexxed / fpl / suddendeath.fpl < prev    next >
Text File  |  1995-07-23  |  2KB  |  104 lines

  1. /***********************************************************
  2.  *
  3.  *  SuddenDeath
  4.  *
  5.  *  Player 1: Control with 'z' and 'x'.
  6.  *  Player 2: Control with ',' and '.'.
  7.  *
  8.  *********/
  9. {
  10.   int view_lines=ReadInfo("view_lines");
  11.   int view_columns=ReadInfo("view_columns");
  12.   string text[view_lines+1];
  13.   int count, game;
  14.   string key;
  15.   string name;
  16.   int dir[5]={-1,0,1,0,-1};
  17.   int p1points=0, p2points=0;
  18.   string blank;
  19.  
  20.   CursorActive(0);
  21.  
  22.   for (count=view_columns-1; count>=0; count--) {
  23.     text[1]+="*";
  24.     blank+=" ";
  25.   }
  26.   text[view_lines]=text[1];
  27.   blank[0]='*';
  28.   blank[view_columns-1]='*';
  29.   
  30.   do {
  31.     int pos1y=view_lines/2, pos1x=view_columns/4;
  32.     int pos2y=pos1y, pos2x=pos1x+view_columns/2;
  33.     int p1dir=1, p2dir=3;
  34.     int p1rot=0, p2rot=0;
  35.  
  36.     int p1y=dir[p1dir];
  37.     int p1x=dir[p1dir+1];
  38.     int p2y=dir[p2dir];
  39.     int p2x=dir[p2dir+1];
  40.  
  41.     int pkey;
  42.  
  43.     while (strlen(GetKey(1)));
  44.  
  45.     for (count=view_lines-1; count>1; count--)
  46.       text[count]=blank;
  47.   
  48.     for (count=view_lines; count>0; count--)
  49.       PrintLine(text[count], count);
  50.  
  51.     game=1;
  52.     while (game) {
  53.       text[pos1y][pos1x]='o';
  54.       PrintLine(text[pos1y], pos1y);
  55.       text[pos2y][pos2x]='O';
  56.       PrintLine(text[pos2y], pos2y);
  57.   
  58.       pkey=2;
  59.       do {
  60.         if (strlen(key=GetKey(1))) {
  61.           switch (key[0]) {
  62.           case 'z': p1rot--; break;
  63.           case 'x': p1rot++; break;
  64.           case ',': p2rot--; break;
  65.           case '.': p2rot++;
  66.           }
  67.         }
  68.       } while (--pkey);
  69.       if (p1rot) {
  70.         if (p1rot>0) {
  71.           p1dir++;
  72.           p1rot--;
  73.         } else {
  74.           p1dir--;
  75.           p1rot++;
  76.         }
  77.         p1y=dir[p1dir&3];
  78.         p1x=dir[(p1dir&3)+1];
  79.       }
  80.       if (p2rot) {
  81.         if (p2rot>0) {
  82.           p2dir++;
  83.           p2rot--;
  84.         } else {
  85.           p2dir--;
  86.           p2rot++;
  87.         }
  88.         p2y=dir[p2dir&3];
  89.         p2x=dir[(p2dir&3)+1];
  90.       }
  91.       if (text[pos1y+=p1y][pos1x+=p1x]!=' ') {
  92.         game=0;
  93.         p2points++;
  94.       }
  95.       if (text[pos2y+=p2y][pos2x+=p2x]!=' ') {
  96.         game=0;
  97.         p1points++;
  98.       }
  99.     }
  100.   } while (Request("Player 1: "+ltostr(p1points)+" points\nPlayer 2: "+ltostr(p2points)+" points", "SUDDEN DEATH SCORE"));
  101.   RedrawScreen(0);
  102.   while (strlen(GetKey(1)));
  103. }
  104.